package gr.aueb.mscis.chord;

import gr.aueb.mscis.configuration.Config;

import java.io.IOException;
import java.net.ServerSocket;

public class RemoteMessageDaemon extends Thread {

	ServerSocket serverSocket = null;
	boolean listening = true;
	private int serverPort = Config.listeningPort;
	private Node node;

	public RemoteMessageDaemon(Node n)
	{
		node=n;
	}
	
	public void run() {
				
		try {
			serverSocket = new ServerSocket(serverPort);
		} catch (IOException e) {
		}

		while (listening) {
			try {
				new RemoteMessageDaemonThread(serverSocket.accept(), node).start();
			} catch (IOException e) {
			}
		}

		try {
			serverSocket.close();
		} catch (IOException e) {
		}
	}
}
